package com.example.administrator.yunniuusedcar.holder;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.administrator.common.base.Global;
import com.example.administrator.common.ui.BaseAdapterRV;
import com.example.administrator.common.ui.BaseHolderRV;
import com.example.administrator.yunniuusedcar.MainActivity;
import com.example.administrator.yunniuusedcar.R;
import com.example.administrator.yunniuusedcar.activity.CommodityDetailsActivity;
import com.example.administrator.yunniuusedcar.model.mode_benn.HomeMenuBean;
import com.example.administrator.yunniuusedcar.model.mode_benn.JiFenShoppingBean;
import com.squareup.picasso.Picasso;

/**
 * 积分商城
 * Created by USER2015 on 2017/12/3.
 */

public class JiFenShoppNRHolder extends BaseHolderRV<JiFenShoppingBean> {

    private ImageView ivJifenpager;
    private TextView tvTitle2;
    private TextView tvMoney1;

    public JiFenShoppNRHolder(Context context, ViewGroup parent,
                              BaseAdapterRV<JiFenShoppingBean> adapter) {
        super(context, parent, adapter, R.layout.fragment_glide_jifen_sport);   // 内容
    }
    // 查找子控件
    @Override
    public void onFindViews(View itemView) {
       initView2();
//
//        // 设置itemView的宽度
//        int width = (int) (Global.mScreenWidth / 4);
//        ViewGroup.LayoutParams param = itemView.getLayoutParams();  //网格布局
//        param.width = width;
//        itemView.setLayoutParams(param);
    }

    // 刷新子控件显示
    @Override
    protected void onRefreshView(JiFenShoppingBean bean1, int position) {  // bean 代墙砖
            bean = (JiFenShoppingBean)bean1;

        Picasso.with(context).load(bean.data.data.get(position).goods_img).into(ivJifenpager);

        tvTitle2.setText(bean.data.data.get(position).goods_name);
        tvMoney1.setText(bean.data.data.get(position).shop_price);
    }

    private void initView2() {
        ivJifenpager = (ImageView) itemView.findViewById(R.id.iv_Jifenpager);  //iv_Jifenpager
        tvTitle2 = (TextView) itemView.findViewById(R.id.tv_title3);
        tvMoney1 = (TextView)itemView.findViewById(R.id.tv_Money3);
    }

    @Override
    protected void onItemClick(View itemView, int position, JiFenShoppingBean bean) {
        super.onItemClick(itemView, position, bean);
        Intent intent =new Intent(MainActivity.mactivity, CommodityDetailsActivity.class);
        intent.putExtra("RanCarid",bean.data.data.get(position).goods_id);
        MainActivity.mactivity.startActivity(intent);
    }
}

